"""
业务流程测试:
查询员工列表-->增加员工信息-->查询添加的员工信息-->修改添加的员工信息-->删除员工信息
"""
# 导包
import requests, app


# 创建员工类
class EmployeeAPI(object):
    def __init__(self):
        self.employee_url = app.BASE_URL + "/api/sys/user"

    def query_employee_list(self, headers):
        return requests.get(url=self.employee_url,
                            params={"page": "1", "size": "10"},
                            headers=headers)

    def insert_employee(self, headers, jsonData):
        return requests.post(url=self.employee_url,
                             headers=headers,
                             json=jsonData)

    def query_employee(self, headers, target):
        url_query = self.employee_url + '/' + target
        print("查询员工的url为:", url_query)
        return requests.get(url=url_query,
                            headers=headers)

    def updata_employee(self, target, headers, jsonData):
        url_modify = self.employee_url + '/' + target
        print("修改员工的URL为:", url_modify)
        return requests.put(url=url_modify,
                            headers=headers,
                            json=jsonData)

    def delect_employee(self, target, headers):
        url_delect = self.employee_url + "/" + target
        print("删除员工的url为:", url_delect)
        return requests.delete(url=url_delect,
                               headers=headers)
